package com.jxud.controller;

import com.jxud.Pojo.PrivacyPolicy;
import com.jxud.Pojo.Result;
import com.jxud.service.PrivacyPolicyService;
import lombok.extern.log4j.Log4j2;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@CrossOrigin(origins = "*")
@RestController
@Slf4j
public class PrivacyPolicyController {

    @Autowired
    private PrivacyPolicyService privacyPolicyService;

    @PostMapping("/api/privacy")
    public Result getPrivacyPolicy() {
        log.info("=========================请求隐私政策数据=================================");
        PrivacyPolicy policy = privacyPolicyService.getActivePolicy();
        Map<String, Object> response = new HashMap<>();
        response.put("version", policy.getVersion());
        response.put("content", policy.getContent()); // 包含HTML标签
        response.put("lastUpdated", policy.getUpdatedTime());
        return Result.success(response);
    }


}
